<?php


abstract class BaseTabHistoriaMedicaPeer {

	
	const DATABASE_NAME = 'xaman';

	
	const TABLE_NAME = 'tab_historia_medica';

	
	const CLASS_DEFAULT = 'lib.model.TabHistoriaMedica';

	
	const NUM_COLUMNS = 27;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const NRO_HISTORIA = 'tab_historia_medica.NRO_HISTORIA';

	
	const FECHA_APERTURA = 'tab_historia_medica.FECHA_APERTURA';

	
	const NACIONALIDAD = 'tab_historia_medica.NACIONALIDAD';

	
	const CEDULA = 'tab_historia_medica.CEDULA';

	
	const CF_FAMILIAR = 'tab_historia_medica.CF_FAMILIAR';

	
	const NOMBRE_PARIENTE = 'tab_historia_medica.NOMBRE_PARIENTE';

	
	const APELLIDO_PARIENTE = 'tab_historia_medica.APELLIDO_PARIENTE';

	
	const CODIGO_CELU = 'tab_historia_medica.CODIGO_CELU';

	
	const TLF_CELU_PARIENTE = 'tab_historia_medica.TLF_CELU_PARIENTE';

	
	const CODIGO_AREA = 'tab_historia_medica.CODIGO_AREA';

	
	const TLF_HAB_PARIENT = 'tab_historia_medica.TLF_HAB_PARIENT';

	
	const DIRECC_PARIENTE = 'tab_historia_medica.DIRECC_PARIENTE';

	
	const RELACION_SEXUAL = 'tab_historia_medica.RELACION_SEXUAL';

	
	const VIDA_SEXUAL = 'tab_historia_medica.VIDA_SEXUAL';

	
	const OBSERVACION_GENERAL = 'tab_historia_medica.OBSERVACION_GENERAL';

	
	const OBSERVACION_MEDIA = 'tab_historia_medica.OBSERVACION_MEDIA';

	
	const TA = 'tab_historia_medica.TA';

	
	const PULSO = 'tab_historia_medica.PULSO';

	
	const TALLA = 'tab_historia_medica.TALLA';

	
	const PESO = 'tab_historia_medica.PESO';

	
	const GRUPO_SANGUINEO = 'tab_historia_medica.GRUPO_SANGUINEO';

	
	const FACTOR_RH = 'tab_historia_medica.FACTOR_RH';

	
	const EXAMEN_FUNCIONAL = 'tab_historia_medica.EXAMEN_FUNCIONAL';

	
	const EXAMEN_FISICO = 'tab_historia_medica.EXAMEN_FISICO';

	
	const MOTIVO_ADMISION = 'tab_historia_medica.MOTIVO_ADMISION';

	
	const DIAGNOSTICO = 'tab_historia_medica.DIAGNOSTICO';

	
	const ESTATUS = 'tab_historia_medica.ESTATUS';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('NroHistoria', 'FechaApertura', 'Nacionalidad', 'Cedula', 'CfFamiliar', 'NombrePariente', 'ApellidoPariente', 'CodigoCelu', 'TlfCeluPariente', 'CodigoArea', 'TlfHabParient', 'DireccPariente', 'RelacionSexual', 'VidaSexual', 'ObservacionGeneral', 'ObservacionMedia', 'Ta', 'Pulso', 'Talla', 'Peso', 'GrupoSanguineo', 'FactorRh', 'ExamenFuncional', 'ExamenFisico', 'MotivoAdmision', 'Diagnostico', 'Estatus', ),
		BasePeer::TYPE_COLNAME => array (TabHistoriaMedicaPeer::NRO_HISTORIA, TabHistoriaMedicaPeer::FECHA_APERTURA, TabHistoriaMedicaPeer::NACIONALIDAD, TabHistoriaMedicaPeer::CEDULA, TabHistoriaMedicaPeer::CF_FAMILIAR, TabHistoriaMedicaPeer::NOMBRE_PARIENTE, TabHistoriaMedicaPeer::APELLIDO_PARIENTE, TabHistoriaMedicaPeer::CODIGO_CELU, TabHistoriaMedicaPeer::TLF_CELU_PARIENTE, TabHistoriaMedicaPeer::CODIGO_AREA, TabHistoriaMedicaPeer::TLF_HAB_PARIENT, TabHistoriaMedicaPeer::DIRECC_PARIENTE, TabHistoriaMedicaPeer::RELACION_SEXUAL, TabHistoriaMedicaPeer::VIDA_SEXUAL, TabHistoriaMedicaPeer::OBSERVACION_GENERAL, TabHistoriaMedicaPeer::OBSERVACION_MEDIA, TabHistoriaMedicaPeer::TA, TabHistoriaMedicaPeer::PULSO, TabHistoriaMedicaPeer::TALLA, TabHistoriaMedicaPeer::PESO, TabHistoriaMedicaPeer::GRUPO_SANGUINEO, TabHistoriaMedicaPeer::FACTOR_RH, TabHistoriaMedicaPeer::EXAMEN_FUNCIONAL, TabHistoriaMedicaPeer::EXAMEN_FISICO, TabHistoriaMedicaPeer::MOTIVO_ADMISION, TabHistoriaMedicaPeer::DIAGNOSTICO, TabHistoriaMedicaPeer::ESTATUS, ),
		BasePeer::TYPE_FIELDNAME => array ('nro_historia', 'fecha_apertura', 'nacionalidad', 'cedula', 'cf_familiar', 'nombre_pariente', 'apellido_pariente', 'codigo_celu', 'tlf_celu_pariente', 'codigo_area', 'tlf_hab_parient', 'direcc_pariente', 'relacion_sexual', 'vida_sexual', 'observacion_general', 'observacion_media', 'ta', 'pulso', 'talla', 'peso', 'grupo_sanguineo', 'factor_rh', 'examen_funcional', 'examen_fisico', 'motivo_admision', 'diagnostico', 'estatus', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('NroHistoria' => 0, 'FechaApertura' => 1, 'Nacionalidad' => 2, 'Cedula' => 3, 'CfFamiliar' => 4, 'NombrePariente' => 5, 'ApellidoPariente' => 6, 'CodigoCelu' => 7, 'TlfCeluPariente' => 8, 'CodigoArea' => 9, 'TlfHabParient' => 10, 'DireccPariente' => 11, 'RelacionSexual' => 12, 'VidaSexual' => 13, 'ObservacionGeneral' => 14, 'ObservacionMedia' => 15, 'Ta' => 16, 'Pulso' => 17, 'Talla' => 18, 'Peso' => 19, 'GrupoSanguineo' => 20, 'FactorRh' => 21, 'ExamenFuncional' => 22, 'ExamenFisico' => 23, 'MotivoAdmision' => 24, 'Diagnostico' => 25, 'Estatus' => 26, ),
		BasePeer::TYPE_COLNAME => array (TabHistoriaMedicaPeer::NRO_HISTORIA => 0, TabHistoriaMedicaPeer::FECHA_APERTURA => 1, TabHistoriaMedicaPeer::NACIONALIDAD => 2, TabHistoriaMedicaPeer::CEDULA => 3, TabHistoriaMedicaPeer::CF_FAMILIAR => 4, TabHistoriaMedicaPeer::NOMBRE_PARIENTE => 5, TabHistoriaMedicaPeer::APELLIDO_PARIENTE => 6, TabHistoriaMedicaPeer::CODIGO_CELU => 7, TabHistoriaMedicaPeer::TLF_CELU_PARIENTE => 8, TabHistoriaMedicaPeer::CODIGO_AREA => 9, TabHistoriaMedicaPeer::TLF_HAB_PARIENT => 10, TabHistoriaMedicaPeer::DIRECC_PARIENTE => 11, TabHistoriaMedicaPeer::RELACION_SEXUAL => 12, TabHistoriaMedicaPeer::VIDA_SEXUAL => 13, TabHistoriaMedicaPeer::OBSERVACION_GENERAL => 14, TabHistoriaMedicaPeer::OBSERVACION_MEDIA => 15, TabHistoriaMedicaPeer::TA => 16, TabHistoriaMedicaPeer::PULSO => 17, TabHistoriaMedicaPeer::TALLA => 18, TabHistoriaMedicaPeer::PESO => 19, TabHistoriaMedicaPeer::GRUPO_SANGUINEO => 20, TabHistoriaMedicaPeer::FACTOR_RH => 21, TabHistoriaMedicaPeer::EXAMEN_FUNCIONAL => 22, TabHistoriaMedicaPeer::EXAMEN_FISICO => 23, TabHistoriaMedicaPeer::MOTIVO_ADMISION => 24, TabHistoriaMedicaPeer::DIAGNOSTICO => 25, TabHistoriaMedicaPeer::ESTATUS => 26, ),
		BasePeer::TYPE_FIELDNAME => array ('nro_historia' => 0, 'fecha_apertura' => 1, 'nacionalidad' => 2, 'cedula' => 3, 'cf_familiar' => 4, 'nombre_pariente' => 5, 'apellido_pariente' => 6, 'codigo_celu' => 7, 'tlf_celu_pariente' => 8, 'codigo_area' => 9, 'tlf_hab_parient' => 10, 'direcc_pariente' => 11, 'relacion_sexual' => 12, 'vida_sexual' => 13, 'observacion_general' => 14, 'observacion_media' => 15, 'ta' => 16, 'pulso' => 17, 'talla' => 18, 'peso' => 19, 'grupo_sanguineo' => 20, 'factor_rh' => 21, 'examen_funcional' => 22, 'examen_fisico' => 23, 'motivo_admision' => 24, 'diagnostico' => 25, 'estatus' => 26, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/TabHistoriaMedicaMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.TabHistoriaMedicaMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = TabHistoriaMedicaPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(TabHistoriaMedicaPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::NRO_HISTORIA);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::FECHA_APERTURA);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::NACIONALIDAD);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::CEDULA);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::CF_FAMILIAR);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::NOMBRE_PARIENTE);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::APELLIDO_PARIENTE);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::CODIGO_CELU);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::TLF_CELU_PARIENTE);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::CODIGO_AREA);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::TLF_HAB_PARIENT);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::DIRECC_PARIENTE);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::RELACION_SEXUAL);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::VIDA_SEXUAL);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::OBSERVACION_GENERAL);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::OBSERVACION_MEDIA);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::TA);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::PULSO);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::TALLA);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::PESO);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::GRUPO_SANGUINEO);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::FACTOR_RH);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::EXAMEN_FUNCIONAL);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::EXAMEN_FISICO);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::MOTIVO_ADMISION);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::DIAGNOSTICO);

		$criteria->addSelectColumn(TabHistoriaMedicaPeer::ESTATUS);

	}

	const COUNT = 'COUNT(tab_historia_medica.NRO_HISTORIA)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT tab_historia_medica.NRO_HISTORIA)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(TabHistoriaMedicaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(TabHistoriaMedicaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = TabHistoriaMedicaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = TabHistoriaMedicaPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return TabHistoriaMedicaPeer::populateObjects(TabHistoriaMedicaPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			TabHistoriaMedicaPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = TabHistoriaMedicaPeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}

	
	public static function doCountJoinTabFamiliares(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(TabHistoriaMedicaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(TabHistoriaMedicaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(TabHistoriaMedicaPeer::CF_FAMILIAR, TabFamiliaresPeer::ID_FAMILIAR);

		$rs = TabHistoriaMedicaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinTabFamiliares(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		TabHistoriaMedicaPeer::addSelectColumns($c);
		$startcol = (TabHistoriaMedicaPeer::NUM_COLUMNS - TabHistoriaMedicaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
		TabFamiliaresPeer::addSelectColumns($c);

		$c->addJoin(TabHistoriaMedicaPeer::CF_FAMILIAR, TabFamiliaresPeer::ID_FAMILIAR);
		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = TabHistoriaMedicaPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);

			$omClass = TabFamiliaresPeer::getOMClass();

			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol);

			$newObject = true;
			foreach($results as $temp_obj1) {
				$temp_obj2 = $temp_obj1->getTabFamiliares(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
										$temp_obj2->addTabHistoriaMedica($obj1); 					break;
				}
			}
			if ($newObject) {
				$obj2->initTabHistoriaMedicas();
				$obj2->addTabHistoriaMedica($obj1); 			}
			$results[] = $obj1;
		}
		return $results;
	}


	
	public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
	{
		$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(TabHistoriaMedicaPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(TabHistoriaMedicaPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$criteria->addJoin(TabHistoriaMedicaPeer::CF_FAMILIAR, TabFamiliaresPeer::ID_FAMILIAR);

		$rs = TabHistoriaMedicaPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}


	
	public static function doSelectJoinAll(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		TabHistoriaMedicaPeer::addSelectColumns($c);
		$startcol2 = (TabHistoriaMedicaPeer::NUM_COLUMNS - TabHistoriaMedicaPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		TabFamiliaresPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + TabFamiliaresPeer::NUM_COLUMNS;

		$c->addJoin(TabHistoriaMedicaPeer::CF_FAMILIAR, TabFamiliaresPeer::ID_FAMILIAR);

		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = TabHistoriaMedicaPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);


					
			$omClass = TabFamiliaresPeer::getOMClass();


			$cls = Propel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getTabFamiliares(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addTabHistoriaMedica($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj2->initTabHistoriaMedicas();
				$obj2->addTabHistoriaMedica($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}

	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return TabHistoriaMedicaPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(TabHistoriaMedicaPeer::NRO_HISTORIA); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(TabHistoriaMedicaPeer::NRO_HISTORIA);
			$selectCriteria->add(TabHistoriaMedicaPeer::NRO_HISTORIA, $criteria->remove(TabHistoriaMedicaPeer::NRO_HISTORIA), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(TabHistoriaMedicaPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(TabHistoriaMedicaPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof TabHistoriaMedica) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(TabHistoriaMedicaPeer::NRO_HISTORIA, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(TabHistoriaMedica $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(TabHistoriaMedicaPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(TabHistoriaMedicaPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(TabHistoriaMedicaPeer::DATABASE_NAME, TabHistoriaMedicaPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = TabHistoriaMedicaPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(TabHistoriaMedicaPeer::DATABASE_NAME);

		$criteria->add(TabHistoriaMedicaPeer::NRO_HISTORIA, $pk);


		$v = TabHistoriaMedicaPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(TabHistoriaMedicaPeer::NRO_HISTORIA, $pks, Criteria::IN);
			$objs = TabHistoriaMedicaPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseTabHistoriaMedicaPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/TabHistoriaMedicaMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.TabHistoriaMedicaMapBuilder');
}
